<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrderProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order_products', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('order_id')->comment('订单id');
            $table->bigInteger('product_id')->comment('商品id');
            $table->bigInteger('user_id')->comment('用户id');
            $table->string('product_name',100)->comment('商品名称');
            $table->bigInteger('image_id')->comment('商品主图');
            $table->decimal('current_price')->comment('创建订单时的价格');
            $table->tinyInteger('activity_type')->comment("活动类型 1：普通  2：团购  3：秒杀");
            $table->bigInteger('activity_id')->nullable()->comment('参与商品活动的id  -1：不参与活动');
            $table->tinyInteger('quantity')->comment('商品数量');
            $table->decimal('total_price',20,2)->comment('商品总价');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_products');
    }
}
